package com.shyroke.daydayzhuanapi.entity;

import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.Set;

@Getter
@Setter
@Entity
@Table(name = "subject")
public class SubjectEntity extends BaseEntity implements Serializable {
    private String title;
    private String content;
    private String summary;
    private String cover;
    private Integer readMount;
    private Boolean isShow;
    private String keywords;
    private Date createTime;
    private Date updateTime;
    private String isCommented;

    @Column(name = "create_id")
    private Integer createId;

    @ManyToOne(fetch = FetchType.LAZY,cascade = CascadeType.PERSIST)
    @JoinColumn(name = "create_id",referencedColumnName = "id",insertable = false, updatable = false)
    private UserEntity user;

    @ManyToMany(cascade = CascadeType.ALL,fetch = FetchType.LAZY)
    @JoinTable(name = "subject_app",joinColumns = @JoinColumn(name = "subject_id",insertable = false, updatable = false),
            inverseJoinColumns = @JoinColumn(name = "app_id",insertable = false, updatable = false))
    private Set<AppEntity> appList;
}